package com.lg.thread.day02.interruptTest;

/**
 * @author LG93
 * @create 2017-08-11 17:24
 **/
@SuppressWarnings("Duplicates")
public class Test {
    public static void main(String[] args) {
//        test1();
//        test2();
        test3();
    }

    public static void test1() {
        try {
            MyThread  myThread = new MyThread();
            myThread.start();
            Thread.sleep(2000);
            myThread.interrupt();
            System.out.println("线程是否停止1 ? =" + myThread.interrupted());
            System.out.println("线程是否停止2 ? =" + myThread.interrupted());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("end");
    }
    public static void test2() {
        try {
            MyThread  myThread = new MyThread();
            myThread.start();
            Thread.sleep(2000);
            myThread.interrupt();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("end");
    }
    public static void test3() {
        try {
            MyThread  myThread = new MyThread();
            myThread.start();
            Thread.sleep(2000);
            myThread.interrupt();
        } catch (InterruptedException e) {
            System.out.println("main catch");
            e.printStackTrace();
        }
        System.out.println("end");
    }


}
